<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            font-size: 18px;
            color: #999;
            background: #242424;
            height: 100vh;
            padding: 0;
            margin: 0;
        }
        .wrapper{
            position: relative;
            height: 800px;
            perspective: 800;
            -webkit-perspective: 800;
        }
        .ad{
            position: absolute;
            left: 50%;
            top:50%;
            width: 840px;
            height: 500px;
            margin-left: -420px;
            margin-top: -250px;
            background: black;
            overflow: hidden;
            border-radius: 3px;
            transform-style: preserve-3d;
            will-change: transform;
            box-shadow: 0 60px 100px rgba(0, 0, 0, .5);
        }
        .layer{
            position: absolute;
            will-change: transform;
        }
        .layer-1,
        .light-2,
        .light-3{
            top: 50%;
            left: 50%;
            margin-left: -630px;
            margin-top: -375px;
            width: 1260px;
            height: 750px;
            transform: scale(0.7);
        }
        .layer-1{
            background-image: url('./IMG/bgc.jpg');
            background-position: 100%;
        }
        .layer-2{
            width: 100%;
            height: 100%;
            top: 15%;
            left: -6%;
            background-position: 100%;
            z-index: 4;
            background: radial-gradient(ellipse closest-side at center,#ffffff,#000000);
            background-image: url('./IMG/1.jpg');
            background-repeat: no-repeat;
            mix-blend-mode:screen;
            /* opacity: 0.9; */
            transform: scale(.7);
        }
        .layer-3{
            opacity: 0.9;
            width: 100%;
            height: 100%;
            top: 15%;
            left: 28%;
            background-image: url('./IMG/2.png');
            transform: scale(0.7);
        }
        .light{
            top: 50%;
            left: 50%;
            margin-left: -840px;
            margin-top: -800px;
            width: 1680px;
            height: 1000px;
            background: radial-gradient(ellipse closest-side at center,#6c6c6c,#000000);
            mix-blend-mode: color-dodge;
            opacity: .6;
            z-index: 3;
        }
    </style>
</head>
<body>
    <div class="wrapper">
        <div class="ad">
            <div class="layer light"></div>
            <div class="layer light light-2"></div>
            <div class="layer layer-1"></div>
            <div class="layer layer-2"></div>
            <div class="layer layer-3"></div>
        </div>
    </div>
    <script>
        const $body = document.body
        const WIDTH = $body.offsetWidth
        const HEIGHT = $body.offsetHeight
        const $ad = document.querySelector('.ad')
        const $light = $ad.querySelector('.light')
        const $layer2 = $ad.querySelector('.layer-2')
        const $layer3 = $ad.querySelector('.layer-3')
        $body.addEventListener('mousemove',moveAd)
        function moveAd(e) {
            const xPer = e.clientX / WIDTH
            const yPer = e.clientY / HEIGHT
            const rotateX = 5-(yPer*10)
            const rotateY = -5+(xPer*10)
            $ad.style.transform = `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`
            const translateX = -5+(xPer*10)
            const translateY = -5+(yPer*10)
            $layer2.style.transform = `scale(.7) translateX(${translateX}px) translateY(${translateY}px)`
            $layer3.style.transform = `scale(.7) translateX(${translateX*2}px) translateY(${translateY*2}px)`
            const lightX = 800- (xPer * 1600)
            const lightY = 300- (yPer * 600)
            $light.style.transform = `translateX(${lightX}px) translateY(${lightY}px)`
        }

    </script>
</body>
</html>